package kiwi.assist.dev.util {
	import kiwi.assist.dev.guieditor.model.PropertyConfig;
	import kiwi.assist.dev.guieditor.model.StyleConfig;
	import kiwi.assist.dev.guieditor.model.format.BooleanFormat;
	import kiwi.assist.dev.guieditor.model.format.ClassFormat;
	import kiwi.assist.dev.guieditor.model.format.IValueFormat;
	import kiwi.assist.dev.guieditor.model.format.NumericFormat;
	import kiwi.assist.dev.guieditor.model.format.StringFormat;
	import kiwi.assist.dev.guieditor.model.format.TFFormat;
	import kiwi.debug.Log;

	/**
	 * @author zhangming.luo
	 */
	public class XMLParseHeler {
		private var data : XML;

		public function XMLParseHeler(data : XML) : void {
			this.data = data;
		}

		/**
		 * <style name="样式名" format="类型" target="目标类型">
		 * </style>
		 */
		public function parseStyle() : StyleConfig {
			var config : StyleConfig = new StyleConfig();
			config.key = data.@name;
			parseFormat(String(data.@format));
			return config;
		}

		public function parseProperty() : PropertyConfig {
			var property : PropertyConfig = new PropertyConfig();
			return property;
		}

		public static function parseFormat(format : String) : IValueFormat {
			switch (format) {
				case "Numeric":
					return new NumericFormat();
				case "Boolean":
					return new BooleanFormat();
				case "String":
					return new StringFormat();
				case "Class":
					return new ClassFormat();
				case "TextFormat":
					return new TFFormat();
			}
			Log.error("错误的类型");
			return null;
		}
	}
}
